home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / etc / bash_completion.d / ooffice.sh < prev    next >
Text File  |  2009-10-22  |  5KB  |  109 lines

  1. # Programmable bash_completion file for the main OpenOffice.org applications
  2. # It is based on /etc/profile.d/complete.bash from SUSE Linux 10.1
  3.  
  4. _def=; _dir=; _file=; _nosp=
  5. if complete -o default _nullcommand &> /dev/null ; then
  6.     _def="-o default"
  7.     _dir="-o dirnames"
  8.     _file="-o filenames"
  9. fi
  10. _minusdd="-d ${_dir}"
  11. _minusdf="-d ${_file}"
  12. if complete -o nospace _nullcommand &> /dev/null ; then
  13.     _nosp="-o nospace"
  14.     _minusdd="${_nosp} ${_dir}"
  15.     _minusdf="${_nosp} ${_dir}"
  16. fi
  17. complete -r _nullcommand &> /dev/null
  18.  
  19. # General OOo expanding shell function
  20. _ooexp_ ()
  21. {
  22.     # bash `complete' is broken because you can not combine
  23.     # -d, -f, and -X pattern without missing directories.
  24.     local c=${COMP_WORDS[COMP_CWORD]}
  25.     local a="${COMP_LINE}"
  26.     local e s g=0 cd dc t=""
  27.     local IFS
  28.  
  29.     shopt -q extglob && g=1
  30.     test $g -eq 0 && shopt -s extglob
  31.     # Don't be fooled by the bash parser if extglob is off by default
  32.     cd='*-?(c)d*'
  33.     dc='*-d?(c)*'
  34.  
  35.     case "${1##*/}" in
  36.     oobase)        e='!*.+(odb|ODB)' ;;
  37.     oofromtemplate)        e='!*.+(stw|STW|dot|DOT|vor|VOR|stc|STC|xlt|XLT|sti|STI|pot|POT|std|STD|stw|STW|dotm|DOTM|dotx|DOTX|potm|POTM|potx|POTX|xltm|XLTM|xltx|XLTX)' ;;
  38.     oodraw)        e='!*.+(sxd|SXD|std|STD|dxf|DXF|emf|EMF|eps|EPS|met|MET|pct|PCT|sgf|SGF|sgv|SGV|sda|SDA|sdd|SDD|vor|VOR|svm|SVM|wmf|WMF|bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|jfif|JFIF|fif|FIF|jpe|JPE|pcd|PCD|pcx|PCX|pgm|PGM|png|PNG|ppm|PPM|psd|PSD|ras|RAS|tga|TGA|tif|TIF|tiff|TIFF|xbm|XBM|xpm|XPM|odg|ODG|otg|OTG|fodg|FODG|odc|ODC|odi|ODI|sds|SDS|wpg|WPG|svg|SVG)' ;;
  39.     oocalc)        e='!*.+(sxc|SXC|stc|STC|dif|DIF|dbf|DBF|xls|XLS|xlw|XLW|xlt|XLT|rtf|RTF|sdc|SDC|vor|VOR|slk|SLK|txt|TXT|htm|HTM|html|HTML|wk1|WK1|wks|WKS|123|123|xml|XML|ods|ODS|ots|OTS|fods|FODS|csv|CSV|xlsb|XLSB|xlsm|XLSM|xlsx|XLSX|xltm|XLTM|xltx|XLTX)' ;;
  40.     oomath)        e='!*.+(sxm|SXM|smf|SMF|mml|MML|odf|ODF)' ;;
  41.     ooweb)        e='!*.+(htm|HTM|html|HTML|stw|STW|txt|TXT|vor|VOR|oth|OTH)' ;;
  42.     ooffice)        e='!*.+(sxd|SXD|std|STD|dxf|DXF|emf|EMF|eps|EPS|met|MET|pct|PCT|sgf|SGF|sgv|SGV|sda|SDA|sdd|SDD|vor|VOR|svm|SVM|wmf|WMF|bmp|BMP|gif|GIF|jpg|JPG|jpeg|JPEG|jfif|JFIF|fif|FIF|jpe|JPE|pcd|PCD|pcx|PCX|pgm|PGM|png|PNG|ppm|PPM|psd|PSD|ras|RAS|tga|TGA|tif|TIF|tiff|TIFF|xbm|XBM|xpm|XPM|odg|ODG|otg|OTG|fodg|FODG|odc|ODC|odi|ODI|sds|SDS|wpg|WPG|svg|SVG|doc|DOC|dot|DOT|rtf|RTF|sxw|SXW|stw|STW|sdw|SDW|vor|VOR|txt|TXT|htm?|HTM?|xml|XML|wp|WP|wpd|WPD|wps|WPS|odt|ODT|ott|OTT|fodt|FODT|docm|DOCM|docx|DOCX|dotm|DOTM|dotx|DOTX|sxm|SXM|smf|SMF|mml|MML|odf|ODF|sxi|SXI|sti|STI|ppt|PPT|pps|PPS|pot|POT|sxd|SXD|sda|SDA|sdd|SDD|sdp|SDP|vor|VOR|cgm|CGM|odp|ODP|otp|OTP|fodp|FODP|ppsm|PPSM|ppsx|PPSX|pptm|PPTM|pptx|PPTX|potm|POTM|potx|POTX|odb|ODB|sxc|SXC|stc|STC|dif|DIF|dbf|DBF|xls|XLS|xlw|XLW|xlt|XLT|rtf|RTF|sdc|SDC|vor|VOR|slk|SLK|txt|TXT|htm|HTM|html|HTML|wk1|WK1|wks|WKS|123|123|xml|XML|ods|ODS|ots|OTS|fods|FODS|csv|CSV|xlsb|XLSB|xlsm|XLSM|xlsx|XLSX|xltm|XLTM|xltx|XLTX|sxg|SXG|odm|ODM|sgl|SGL|stw|STW|dot|DOT|vor|VOR|stc|STC|xlt|XLT|sti|STI|pot|POT|std|STD|stw|STW|dotm|DOTM|dotx|DOTX|potm|POTM|potx|POTX|xltm|XLTM|xltx|XLTX|htm|HTM|html|HTML|stw|STW|txt|TXT|vor|VOR|oth|OTH)' ;;
  43.     oowriter)        e='!*.+(doc|DOC|dot|DOT|rtf|RTF|sxw|SXW|stw|STW|sdw|SDW|vor|VOR|txt|TXT|htm?|HTM?|xml|XML|wp|WP|wpd|WPD|wps|WPS|odt|ODT|ott|OTT|fodt|FODT|docm|DOCM|docx|DOCX|dotm|DOTM|dotx|DOTX|sxg|SXG|odm|ODM|sgl|SGL)' ;;
  44.     ooimpress)        e='!*.+(sxi|SXI|sti|STI|ppt|PPT|pps|PPS|pot|POT|sxd|SXD|sda|SDA|sdd|SDD|sdp|SDP|vor|VOR|cgm|CGM|odp|ODP|otp|OTP|fodp|FODP|ppsm|PPSM|ppsx|PPSX|pptm|PPTM|pptx|PPTX|potm|POTM|potx|POTX)' ;;
  45.     unopkg)        e='!*.+(oxt|OXT)' ;;
  46.     *)            e='!*'
  47.     esac
  48.  
  49.     case "$(complete -p ${1##*/} 2> /dev/null)" in
  50.     *-d*)    ;;
  51.     *) s="-S/"
  52.     esac
  53.  
  54.     IFS='
  55. '
  56.     case "$c" in
  57.     \$\(*\))       eval COMPREPLY=\(${c}\) ;;
  58.     \$\(*)        COMPREPLY=($(compgen -c -P '$(' -S ')'  -- ${c#??}))    ;;
  59.     \`*\`)       eval COMPREPLY=\(${c}\) ;;
  60.     \`*)        COMPREPLY=($(compgen -c -P '\`' -S '\`' -- ${c#?}))    ;;
  61.     \$\{*\})       eval COMPREPLY=\(${c}\) ;;
  62.     \$\{*)        COMPREPLY=($(compgen -v -P '${' -S '}'  -- ${c#??}))    ;;
  63.     \$*)        COMPREPLY=($(compgen -v -P '$'          -- ${c#?}))    ;;
  64.     \~*/*)        COMPREPLY=($(compgen -f -X "$e"         -- ${c}))    ;;
  65.     \~*)        COMPREPLY=($(compgen -u ${s}         -- ${c}))    ;;
  66.     *@*)        COMPREPLY=($(compgen -A hostname -P '@' -S ':' -- ${c#*@})) ;;
  67.     *[*?[]*)        COMPREPLY=($(compgen -G "${c}"))            ;;
  68.     *[?*+\!@]\(*\)*)
  69.     if test $g -eq 0 ; then
  70.             COMPREPLY=($(compgen -f -X "$e" -- $c))
  71.             test $g -eq 0 && shopt -u extglob
  72.             return
  73.     fi
  74.             COMPREPLY=($(compgen -G "${c}"))            ;;
  75.     *)
  76.     if test "$c" = ".." ; then
  77.             COMPREPLY=($(compgen -d -X "$e" -S / ${_nosp} -- $c))
  78.     else
  79.             for s in $(compgen -f -X "$e" -- $c) ; do
  80.                 if test -d $s ; then
  81.                 COMPREPLY=(${COMPREPLY[@]} $(compgen -f -X "$e" -S / -- $s))
  82.                 elif test -z "$t" ; then
  83.                 COMPREPLY=(${COMPREPLY[@]} $s)
  84.                 else
  85.                 case "$(file -b $s 2> /dev/null)" in
  86.                 $t) COMPREPLY=(${COMPREPLY[@]} $s)        ;;
  87.                 esac
  88.                 fi
  89.             done
  90.     fi                                    ;;
  91.     esac
  92.     test $g -eq 0 && shopt -u extglob
  93. }
  94.  
  95.  
  96. complete -d -X '.[^./]*' -F _ooexp_ ${_file} \
  97.                     oobase \
  98.                     oofromtemplate \
  99.                     oodraw \
  100.                     oocalc \
  101.                     oomath \
  102.                     ooweb \
  103.                     ooffice \
  104.                     oowriter \
  105.                     ooimpress \
  106.                     unopkg
  107.  
  108. unset _def _dir _file _nosp _minusdd _minusdf
  109.